import { VxeColumnProps } from 'vxe-table';

export interface ColumnsFrom extends VxeColumnProps {
  formHidden?: boolean;
  fieldType?: string;
  defaultValue?: string;
  isRow?: boolean;
}

const fromCols = [
  {
    title: '编码',
    field: 'code',
    isRow: true
  },
  {
    title: '名称',
    field: 'name',
    isRow: false
  },
  {
    title: '类型',
    field: 'format',
    isRow: false
  },
  {
    title: '前缀',
    field: 'prefix',
    isRow: false
  },
  {
    title: '流水位数',
    field: 'digit',
    isRow: false
  },
  {
    title: '流水号',
    field: 'mantissa',
    isRow: false
  }
] as ColumnsFrom[];

export const getFormCols = () => {
  const result = [] as any;
  let index = 0;
  const tempAry = [] as any[];
  for (let i = 0; i < fromCols.length; i++) {
    if (fromCols[i].isRow) {
      result.push([fromCols[i]]);
    } else {
      if (index == 1) {
        tempAry.push(fromCols[i]);
        result.push(JSON.parse(JSON.stringify(tempAry)));
        index = 0;
        tempAry.length = 0;
      } else {
        tempAry.push(fromCols[i]);
        index = index + 1;
      }
    }
  }
  if (tempAry.length > 0) {
    result.push(tempAry);
  }
  return result;
};
